/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.proracing.app.eitinerer.activities;

import static android.R.attr.data;  
import android.app.Activity;  
import android.os.Bundle; 
import android.text.InputType; 
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.proracing.app.eitinerer.helpers.mc_Constants;

/**
 *
 * @author mateusz
 */
public class mc_CreateRallyActivity extends Activity {

    private EditText lr_NumLoops, lr_NumLoops2, lr_Loop1, lr_Loop2, lr_Loop3, lr_Loop4, lr_Loop5, lr_Loop6;
    private mc_Constants lo_Const;
    private Button lr_ButtonAdd, lr_ButtonAdd2;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.create_rally); 
                
        lo_Const = new mc_Constants();
        
        lr_NumLoops = (EditText)findViewById(R.id.num_loops);        
        lr_ButtonAdd = (Button)findViewById(R.id.buttonAdd);
        lr_ButtonAdd.getBackground().setAlpha(90);                           
        lr_ButtonAdd.setOnClickListener(addListener);
    }
    
    private final View.OnClickListener addListener = new View.OnClickListener() {
        public void onClick(View v) {
            String lv_Loopcnts = lr_NumLoops.getText().toString();
            int lv_Loopcnt = Integer.parseInt(lv_Loopcnts);
                      
            
            /*
            if ((lv_Loopcnt < 0) || (lv_Loopcnt > 6)) { 
                Toast.makeText(getApplicationContext(), "Niepoprawna liczba pętli.",
                Toast.LENGTH_LONG).show();
            }
            */
            setContentView(R.layout.create_rally_1);
            lr_NumLoops2 = (EditText)findViewById(R.id.num_loops2);
            lr_NumLoops2.setText(lv_Loopcnts);
            lr_NumLoops2.setEnabled(false);
            lr_NumLoops2.setInputType(InputType.TYPE_NULL);
            lr_NumLoops2.setFocusable(false);
                        
            if (lr_ButtonAdd2 == null) {
                lr_ButtonAdd2 = (Button)findViewById(R.id.buttonAdd2);
                lr_ButtonAdd2.setOnClickListener(addListener);
                lr_ButtonAdd2.setEnabled(false);
                lr_ButtonAdd2.setInputType(InputType.TYPE_NULL);
                lr_ButtonAdd2.setFocusable(false);
            }
            
            for(int i=lv_Loopcnt+1;i<=lo_Const.mc_loopcnt;i++) {
                switch(i) {
                    case 1:
                        lr_Loop1 = (EditText)findViewById(R.id.loop1);
                        lr_Loop1.setEnabled(false);
                        lr_Loop1.setInputType(InputType.TYPE_NULL);
                        lr_Loop1.setFocusable(false);
                    case 2:
                        lr_Loop2 = (EditText)findViewById(R.id.loop2);
                        lr_Loop2.setEnabled(false);
                        lr_Loop2.setInputType(InputType.TYPE_NULL);
                        lr_Loop2.setFocusable(false);
                    case 3:
                        lr_Loop3 = (EditText)findViewById(R.id.loop3);
                        lr_Loop3.setEnabled(false);
                        lr_Loop3.setInputType(InputType.TYPE_NULL);
                        lr_Loop3.setFocusable(false);
                    case 4:
                        lr_Loop4 = (EditText)findViewById(R.id.loop4);
                        lr_Loop4.setEnabled(false);
                        lr_Loop4.setInputType(InputType.TYPE_NULL);
                        lr_Loop4.setFocusable(false);
                    case 5:
                        lr_Loop5 = (EditText)findViewById(R.id.loop5);
                        lr_Loop5.setEnabled(false);
                        lr_Loop5.setInputType(InputType.TYPE_NULL);
                        lr_Loop5.setFocusable(false);
                    case 6:
                        lr_Loop6 = (EditText)findViewById(R.id.loop6);
                        lr_Loop6.setEnabled(false);
                        lr_Loop6.setInputType(InputType.TYPE_NULL);
                        lr_Loop6.setFocusable(false);
                }
            }
        }
    };
}
